﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace AR.Validation
{
    public static class ValidationFunctions
    {
        public static bool ValidateEmail(string email)
        {
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            if (email != null)
            {
                Match match = regex.Match(email);
                if (match.Success)
                    return true;

                else
                    return false;
            }else
            return false;
        }

        //public bool ValidateTextFields(List<TextBox> array)
        //{
        //    bool _returnValue = true;
        //    for (int i = 0; i < array.Count; i++)
        //    {
        //        if (string.IsNullOrWhiteSpace(array[i].Text))
        //            _returnValue = false;
        //    }
        //    return _returnValue;
        //}
      
        public static bool ValidateOnlyLetters(string chaine)
        {
            Regex regex = new Regex(@"^[a-zA-Zéè]+$");
            if ( ! string.IsNullOrWhiteSpace(chaine))
            {
                Match match = regex.Match(chaine);
                if (match.Success)
                    return true;
                else
                    return false;
            }
            else
                return false;
        }

        public static bool ValidateFileLowerThan4MO( FileInfo file)
        {
            if (file.Length < 4194304)
                return true;


            return false;

        }

        public static bool isEmpty(string chaine)
        {
            if(string.IsNullOrWhiteSpace(chaine))
            {
                return true;
            }
            return false;
        }
        public static bool ValidateOnlyNumbers(string chaine)
        {
            Regex regex = new Regex(@"^\d+$");
            if (!string.IsNullOrWhiteSpace(chaine))
            {
                Match match = regex.Match(chaine);
                if (match.Success)
                    return true;
                else
                    return false;
            }
            else
                return false;
        }

        public static bool ValidateGCM(string chaine)
        {
            if (!string.IsNullOrWhiteSpace(chaine))
            {
                if (ValidateOnlyNumbers(chaine))
                {
                    int x = int.Parse(chaine);
                    if ((x >= 1) && (x <= 10))
                    {
                        return true;
                    }
                    else
                        return false;
                }

                return false;
            }
            else
                return false;
        }

        public static bool ValidatePhone(string chaine)
        {
            Regex regex = new Regex(@"^\d{10}$");
            if (!string.IsNullOrWhiteSpace(chaine))
            {
                Match match = regex.Match(chaine);
                if (match.Success)
                { return true; }
                return false;
            }
            else return false;
        }


    }
}

